package cn.netswap.jeegorilla.framework.security.social;

import cn.netswap.jeegorilla.framework.security.consts.SecurityConstants;
import org.springframework.context.annotation.Configuration;
import org.springframework.social.security.SocialAuthenticationFilter;
import org.springframework.social.security.SpringSocialConfigurer;


public class SocialConfigurer extends SpringSocialConfigurer {

    private String filterProcessesUrl;

    public SocialConfigurer(String filterProcessesUrl) {
        this.filterProcessesUrl = filterProcessesUrl;
        super.alwaysUsePostLoginUrl(true);
        super.postLoginUrl(SecurityConstants.ADMIN_INDEX);
        super.connectionAddedRedirectUrl(SecurityConstants.DEFAULT_LOGIN_URL);
    }

    @Override
    protected <T> T postProcess(T object) {
        SocialAuthenticationFilter filter = (SocialAuthenticationFilter) super.postProcess(object);
        filter.setFilterProcessesUrl(filterProcessesUrl);
        filter.setConnectionAddedRedirectUrl("/getOrderList");
        return (T) filter;
    }

}
